﻿<Window x:Class="Adan.Client.Dialogs.GroupsEditDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Groups" 
        ResizeMode="NoResize" 
        ShowInTaskbar="False" 
        WindowStartupLocation="CenterOwner" 
        WindowStyle="ToolWindow" 
        mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        Width="300"
        Height="300" xmlns:Utils="clr-namespace:Adan.Client.Common.Utils;assembly=Adan.Client.Common" Style="{StaticResource DefaultWindowStyle}">
    <Window.Resources>
        <Utils:InverseBooleanConverter x:Key="InverseBooleanConverter" />
    </Window.Resources>
    <Grid Margin="3">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <ListBox Grid.Row="0" Margin="0,0,0,5" ItemsSource="{Binding Path=Groups}" SelectedItem="{Binding Path=SelectedGroup}" Name="lstGroups">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch" Background="Transparent">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <CheckBox IsChecked="{Binding Path=IsEnabled, Mode=TwoWay}" IsEnabled="{Binding Path=IsBuildIn, Converter={StaticResource InverseBooleanConverter}}" VerticalAlignment="Center" Grid.Column="0"/>
                        <TextBlock Text="{Binding Path=Name}" Margin="10,0,0,3" VerticalAlignment="Center"  Grid.Column="1"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <StackPanel Grid.Row="1" Margin="0,0,0,5">
            <Label>New group name:</Label>
            <TextBox Text="{Binding Path=NewGroupName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Name="txtNewGroupName" AcceptsReturn="False"/>
        </StackPanel>      
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="2">
            <Button HorizontalAlignment="Left" Command="{Binding Path=AddGroupCommand}" CommandParameter="{Binding ElementName=txtNewGroupName, Path=Text}" MinWidth="50">Add</Button>
            <Button HorizontalAlignment="Left" Margin="5,0,0,0" Command="{Binding Path=DeleteGroupCommand}" CommandParameter="{Binding ElementName=lstGroups, Path=SelectedItem}" MinWidth="50">Delete</Button>
        </StackPanel>
        <Button Click="HandleCloseClick" HorizontalAlignment="Right" Grid.Row="2" IsCancel="True" MinWidth="50">Close</Button>
    </Grid>
</Window>
